﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;
using SYcwpb.Views;

namespace SYcwpb
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class LoginView : Window
    {
        private ViewModels.LoginViewModel viewModel;

        public LoginView()
        {
            InitializeComponent();
            viewModel = new ViewModels.LoginViewModel(this);

            this.DataContext = viewModel;
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                if (viewModel.UpdateHeadImageThread != null && viewModel.UpdateHeadImageThread.IsAlive)
                {
                    viewModel.UpdateHeadImageThread.Abort();
                }
            }
            catch (System.Exception ex)
            {
                string err = ex.Message;
            }
            finally
            {
            }

            if (viewModel.isLogining)
            {
                new MainView().Show();
            }

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Helpers.SYCWPBGlobalvariables.globalvariables.log.writeInfo("============程序启动===========");
        }
    }
}
